package com.yanfan.zutai.service.impl;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.yanfan.common.utils.DateUtils;
import com.yanfan.zutai.domain.BDeviceZtBind;
import com.yanfan.zutai.mapper.BDeviceZtBindMapper;
import com.yanfan.zutai.service.IBDeviceZtBindService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 云组态组件关联Service业务层处理
 *
 * @author ruoyi
 * @date 2022-05-23
 */
@Service
public class BDeviceZtBindServiceImpl implements IBDeviceZtBindService {
    @Autowired
    private BDeviceZtBindMapper bDeviceZtBindMapper;

    /**
     * 查询云组态组件关联
     *
     * @param id 云组态组件关联ID
     * @return 云组态组件关联
     */
    @Override
    public BDeviceZtBind selectBDeviceZtBindById(Long id) {
        return bDeviceZtBindMapper.selectBDeviceZtBindById(id);
    }

    /**
     * 查询云组态组件关联列表
     *
     * @param bDeviceZtBind 云组态组件关联
     * @return 云组态组件关联
     */
    @Override
    public List<BDeviceZtBind> selectBDeviceZtBindList(BDeviceZtBind bDeviceZtBind) {
        return bDeviceZtBindMapper.selectBDeviceZtBindList(bDeviceZtBind);
    }

    /**
     * 新增云组态组件关联
     *
     * @param bDeviceZtBind 云组态组件关联
     * @return 结果
     */
    @Override
    public int insertBDeviceZtBind(BDeviceZtBind bDeviceZtBind) {
        bDeviceZtBind.setCreateTime(DateUtils.getNowDate());
        Snowflake snowflake = IdUtil.getSnowflake(6, 2);
        long id = snowflake.nextId();
        bDeviceZtBind.setId(id);
        return bDeviceZtBindMapper.insertBDeviceZtBind(bDeviceZtBind);
    }

    /**
     * 修改云组态组件关联
     *
     * @param bDeviceZtBind 云组态组件关联
     * @return 结果
     */
    @Override
    public int updateBDeviceZtBind(BDeviceZtBind bDeviceZtBind) {
        bDeviceZtBind.setUpdateTime(DateUtils.getNowDate());
        return bDeviceZtBindMapper.updateBDeviceZtBind(bDeviceZtBind);
    }

    /**
     * 批量删除云组态组件关联
     *
     * @param ids 需要删除的云组态组件关联ID
     * @return 结果
     */
    @Override
    public int deleteBDeviceZtBindByIds(Long[] ids) {
        return bDeviceZtBindMapper.deleteBDeviceZtBindByIds(ids);
    }

    /**
     * 删除云组态组件关联信息
     *
     * @param id 云组态组件关联ID
     * @return 结果
     */
    @Override
    public int deleteBDeviceZtBindById(Long id) {
        return bDeviceZtBindMapper.deleteBDeviceZtBindById(id);
    }
}
